package com.qhy.springcloud.controller;

import com.qhy.springcloud.api.Dept;
import com.qhy.springcloud.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @author qiuhongyu
 * @date 2020/9/25 18:25
 */
@RestController
public class FeignDeptController {
    @Autowired
    private DeptClientService deptClientService;

    /**
     * 新增部门信息
     *
     * @param dept
     * @return
     */
    @PostMapping("addDept")
    public boolean addDept(Dept dept) {
        boolean b = deptClientService.addDept(dept);
        return true;
    }

    /**
     * 根据部门id查询部门信息
     *
     * @param id
     * @return
     */
    @GetMapping("/queryDept/{id}")
    public Dept queryDept(@PathVariable("id") Long id) {
        Dept dept = deptClientService.queryDept(id);
        return dept;
    }

    @GetMapping("queryDepts")
    public List<Dept> queryDepts() {
        List<Dept> deptList = deptClientService.queryDepts();
        return deptList;
    }

}
